package com.hongding.sealcenter.enums;

import lombok.Getter;

/**
 * 算法OID标识
 * 详细见：https://blog.csdn.net/qq_42383970/article/details/135843534
 */
@Getter
public enum AlgorithmOIDEnum {
    SHA1withRSA("SHA1withRSA","1.2.840.113549.1.1.5"),
    SHA256withRSA("SHA256withRSA","1.2.156.197.1.506"),
    SM3withSM2("SM3withSM2","1.2.156.197.1.501"),
    RSA("RSA","1.2.840.113549.1.1.1"),
    ECC("ECC","1.2.840.10045.2.1");

    private String code;
    private String oid;
    AlgorithmOIDEnum(String code, String oid) {
        this.code = code;
        this.oid = oid;
    }
    /**
     * 目前使用的摘要算法
     * @param algorithm
     * @return
     */
    public static AlgorithmOIDEnum buildSignAlg(SignAlgEnum algorithm) {
        if (SignAlgEnum.equalsSM2(algorithm.getCode())) {
            return SM3withSM2;
        } else {
            return SHA256withRSA;
        }
    }
}
